#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

struct TreeNode {
     int val;
     TreeNode *left;
     TreeNode *right;
     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 };

void pathSumHelper(TreeNode *root, int sum, vector<vector<int> > &ans, vector<int> &cur)
{
    if (!root) return;
    sum -= root->val;
    cur.push_back(root->val);
    if (sum == 0 && !root->left && !root->right) {
	ans.push_back(cur);
	cur.pop_back();
	return;
    }
    pathSumHelper(root->left, sum, ans, cur);
    pathSumHelper(root->right, sum, ans, cur);
    cur.pop_back();
}

class Solution {
public:
    vector<vector<int> > pathSum(TreeNode *root, int sum) {
	vector<vector<int> > ans;
	if (!root) return ans;
	vector<int> cur;
	pathSumHelper(root, sum, ans, cur);
        
    }
};


//pass all the test in leet code.
int main(int argc, char **argv)
{

}
